<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\video\model;

use think\Model;

/**
 * 视频模型
 * @package app\user_center\model
 */
class VideoPlayGoods extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'xm_video_play_goods';


    /**
     * 排除已有数据添加新数据
     * @param uid string 用户id
     * @param video_id string 视频id
     * @param main_title string 视频标题
     * @author dou <51779987@qq.com>
     * @return array_out(code, message, (int)id)
     */
    public function withoutAddData($play_id, $goods_id_array){
        $temp_list = [];
        $un_set = self::destroy(['play_id'=>$play_id]);
        foreach ($goods_id_array as $key => $value) {
            $temp_list[] =[
                'play_id' => $play_id,
                'goods_id' => $value,
            ];
        }
        $res1 = $this -> isUpdate(false) -> saveAll($temp_list);
        if($res1){
            return array_out(200, 'success', []);
        }else{
            return array_out(-1001, 'error');
        }
    }
}
